﻿// RS232Dlg.cpp: 实现文件
//

#include "pch.h"
#include "ProjectAA.h"
#include "RS232Dlg.h"
#include "afxdialogex.h"


// CRS232Dlg 对话框

IMPLEMENT_DYNAMIC(CRS232Dlg, CDialogEx)

CRS232Dlg::CRS232Dlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_RS232, pParent)
	, m_bPassRfid(FALSE)
	, m_nCom1(0)
	, m_nPort1(0)
	, m_nCom2(0)
	, m_nPort2(0)
	, m_nCom3(0)
	, m_nPort3(0)
	, m_nCom4(0)
	, m_nPort4(0)
	, m_nScrewFlag(FALSE)
	, m_nScrewCom(0)
	, m_nScrewPort(0)
	, m_nComNo_Weiyi(0)
	, m_nComPort_Weiyi(0)
{

}

CRS232Dlg::~CRS232Dlg()
{
}

void CRS232Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Check(pDX, IDC_CHECK1, m_bPassRfid);
	DDX_Text(pDX, IDC_EDIT_COM1, m_nCom1);
	DDX_Text(pDX, IDC_EDIT_PORT1, m_nPort1);
	DDX_Text(pDX, IDC_EDIT_COM2, m_nCom2);
	DDX_Text(pDX, IDC_EDIT_PORT3, m_nPort2);
	DDX_Text(pDX, IDC_EDIT_COM3, m_nCom3);
	DDX_Text(pDX, IDC_EDIT_PORT4, m_nPort3);
	DDX_Text(pDX, IDC_EDIT_COM4, m_nCom4);
	DDX_Text(pDX, IDC_EDIT_PORT5, m_nPort4);
	DDX_Control(pDX, IDC_COMBO1, m_comboPallent);
	DDX_Check(pDX, IDC_CHECK3, m_nScrewFlag);
	DDX_Text(pDX, IDC_EDIT_COM5, m_nScrewCom);
	DDX_Text(pDX, IDC_EDIT_PORT6, m_nScrewPort);
	DDX_Text(pDX, IDC_EDIT_COM6, m_nComNo_Weiyi);
	DDX_Text(pDX, IDC_EDIT_PORT7, m_nComPort_Weiyi);
}


BEGIN_MESSAGE_MAP(CRS232Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CRS232Dlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON3, &CRS232Dlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON2, &CRS232Dlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON6, &CRS232Dlg::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON28, &CRS232Dlg::OnBnClickedButton28)
	ON_BN_CLICKED(IDC_BUTTON4, &CRS232Dlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &CRS232Dlg::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON10, &CRS232Dlg::OnBnClickedButton10)
	ON_BN_CLICKED(IDC_BUTTON26, &CRS232Dlg::OnBnClickedButton26)
	ON_BN_CLICKED(IDC_BUTTON27, &CRS232Dlg::OnBnClickedButton27)
	ON_BN_CLICKED(IDC_BUTTON29, &CRS232Dlg::OnBnClickedButton29)
	ON_BN_CLICKED(IDC_BUTTON30, &CRS232Dlg::OnBnClickedButton30)
	ON_BN_CLICKED(IDC_BUTTON31, &CRS232Dlg::OnBnClickedButton31)
	ON_BN_CLICKED(IDC_BUTTON32, &CRS232Dlg::OnBnClickedButton32)
	ON_BN_CLICKED(IDC_BUTTON33, &CRS232Dlg::OnBnClickedButton33)
	ON_BN_CLICKED(IDC_BUTTON34, &CRS232Dlg::OnBnClickedButton34)
	ON_BN_CLICKED(IDC_BUTTON35, &CRS232Dlg::OnBnClickedButton35)
	ON_BN_CLICKED(IDC_BUTTON7, &CRS232Dlg::OnBnClickedButton7)
	ON_BN_CLICKED(IDC_BUTTON8, &CRS232Dlg::OnBnClickedButton8)
	ON_BN_CLICKED(IDC_BUTTON9, &CRS232Dlg::OnBnClickedButton9)
	ON_BN_CLICKED(IDC_BUTTON37, &CRS232Dlg::OnBnClickedButton37)
	ON_BN_CLICKED(IDC_BUTTON38, &CRS232Dlg::OnBnClickedButton38)
	ON_BN_CLICKED(IDC_BUTTON39, &CRS232Dlg::OnBnClickedButton39)
	ON_BN_CLICKED(IDC_BUTTON40, &CRS232Dlg::OnBnClickedButton40)
END_MESSAGE_MAP()


// CRS232Dlg 消息处理程序


BOOL CRS232Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	m_comboPallent.ResetContent();
	for (int i = 0; i < 60; i++) {
		CString cstr;
		cstr.Format(L"%02d", i + 1);
		m_comboPallent.AddString(cstr.GetBuffer());
	}
	m_comboPallent.SetCurSel(0);

	ReadConfigIni();

	return TRUE; 
}


void CRS232Dlg::OnCancel()
{

	CDialogEx::OnCancel();
}

void CRS232Dlg::ReadConfigIni()
{
	m_nCom1 = gSystemMgr.m_nComNo1;
	m_nPort1 = gSystemMgr.m_nComPort1;
	m_nCom2 = gSystemMgr.m_nComNo2;
	m_nPort2 = gSystemMgr.m_nComPort2;
	m_bPassRfid = gSystemMgr.m_nPassRfidFlag;
	m_nCom3 = gSystemMgr.m_nComNo3; m_nPort3 = gSystemMgr.m_nComPort3;
	m_nCom4 = gSystemMgr.m_nComNo4;
	m_nPort4 = gSystemMgr.m_nComPort4;

	m_nScrewFlag = gSystemMgr.m_nScrewFlag;
	m_nScrewCom = gSystemMgr.m_nScrewCom;
	m_nScrewPort = gSystemMgr.m_nScrewPort;

	m_nComNo_Weiyi = gSystemMgr.m_nComNo_Weiyi;
	m_nComPort_Weiyi = gSystemMgr.m_nComPort_Weiyi;

	UpdateData(FALSE);
}

void CRS232Dlg::SaveValueToConfig()
{
	UpdateData(TRUE);

	gSystemMgr.m_nComNo1 = m_nCom1;
	gSystemMgr.m_nComPort1 = m_nPort1;
	gSystemMgr.m_nComNo2 = m_nCom2;
	gSystemMgr.m_nComPort2 = m_nPort2;
	gSystemMgr.m_nPassRfidFlag = m_bPassRfid;
	gSystemMgr.m_nComNo3 = m_nCom3; 
	gSystemMgr.m_nComPort3 = m_nPort3;
	gSystemMgr.m_nComNo4 = m_nCom4;
	gSystemMgr.m_nComPort4 = m_nPort4;

	gSystemMgr.m_nScrewFlag = m_nScrewFlag;
	gSystemMgr.m_nScrewCom = m_nScrewCom;
	gSystemMgr.m_nScrewPort = m_nScrewPort;

	gSystemMgr.m_nComNo_Weiyi = m_nComNo_Weiyi;
	gSystemMgr.m_nComPort_Weiyi = m_nComPort_Weiyi;

	CString cstr;
	cstr.Format(L"%d", gSystemMgr.m_nComNo1);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComNo1", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComPort1);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComPort1", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComNo2);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComNo2", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComPort2);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComPort2", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nPassRfidFlag);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nPassRfidFlag", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComNo3); gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComNo3", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComPort3);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComPort3", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComNo4);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComNo4", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComPort4);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComPort4", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComNo_Weiyi);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComNo_Weiyi", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nComPort_Weiyi);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nComPort_Weiyi", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nScrewFlag);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nScrewFlag", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nScrewCom);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nScrewCom", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nScrewPort);
	gSystemMgr.m_cRS232ConfigIni.SaveConfigIni(L"RS232", L"m_nScrewPort", cstr);

	gSystemLog.DisplayLogAndSave(L"RS232保存数据完成", LV_EVENT);
}


void CRS232Dlg::OnBnClickedButton1()
{
	SaveValueToConfig();
}


void CRS232Dlg::OnBnClickedButton3()
{
	gSystemMgr.m_nButtonValue = 30;
}


void CRS232Dlg::OnBnClickedButton2()
{
	if (gSystemMgr.m_cRfidComm1.get_com_port() == NULL) {
		int err = gSystemMgr.m_cRfidComm1.com_open(gSystemMgr.m_nComNo1, gSystemMgr.m_nComPort1, EVENPARITY);
		if (err != 1) {
			CString cstr;
			cstr.Format(L"Com1 Error %d", err);
			gSystemLog.DisplayLogAndSave(cstr.GetBuffer(), LV_EVENT);
			gSystemMgr.Com1ConnectFlag = 0;
		}
		else
			gSystemMgr.Com1ConnectFlag = 1;
	}
}


void CRS232Dlg::OnBnClickedButton6()
{
	if (gSystemMgr.m_cRfidComm2.get_com_port() == NULL) {
		int err = gSystemMgr.m_cRfidComm2.com_open(gSystemMgr.m_nComNo2, gSystemMgr.m_nComPort2, EVENPARITY);
		if (err != 1) {
			CString cstr;
			cstr.Format(L"Com2 Error %d", err);
			gSystemLog.DisplayLogAndSave(cstr.GetBuffer(), LV_EVENT);
			gSystemMgr.Com2ConnectFlag = 0;
		}
		else
			gSystemMgr.Com2ConnectFlag = 1;
	}
}


void CRS232Dlg::OnBnClickedButton28()
{
	if (gSystemMgr.m_cRfidComm3.get_com_port() == NULL) {
		int err = gSystemMgr.m_cRfidComm3.com_open(gSystemMgr.m_nComNo3, gSystemMgr.m_nComPort3, EVENPARITY);
		if (err != 1) {
			CString cstr;
			cstr.Format(L"Com3 Error %d", err);
			gSystemLog.DisplayLogAndSave(cstr.GetBuffer(), LV_EVENT);
			gSystemMgr.Com3ConnectFlag = 0;
		}
		else
			gSystemMgr.Com3ConnectFlag = 1;
	}
}


void CRS232Dlg::OnBnClickedButton4()
{
	gSystemMgr.m_nButtonValue = 31;
}


void CRS232Dlg::OnBnClickedButton5()
{
	gSystemMgr.m_nButtonValue = 32;
}


void CRS232Dlg::OnBnClickedButton10()
{
	gSystemMgr.m_nButtonValue = 33;
}


void CRS232Dlg::OnBnClickedButton26()
{
	gSystemMgr.m_nButtonValue = 34;
}


void CRS232Dlg::OnBnClickedButton27()
{
	gSystemMgr.m_nButtonValue = 35;
}


void CRS232Dlg::OnBnClickedButton29()
{
	gSystemMgr.m_nButtonValue = 36;
}


void CRS232Dlg::OnBnClickedButton30()
{
	gSystemMgr.m_nButtonValue = 37;
}


void CRS232Dlg::OnBnClickedButton31()
{
	gSystemMgr.m_nButtonValue = 38;
}


void CRS232Dlg::OnBnClickedButton32()
{
	if (gSystemMgr.m_cComm4.get_com_port() == NULL) {
		int err = gSystemMgr.m_cComm4.com_open(gSystemMgr.m_nComNo_Weiyi, gSystemMgr.m_nComPort_Weiyi, NOPARITY);
		if (err != 1) {
			CString cstr;
			cstr.Format(L"ComWeiyi Error %d", err);
			gSystemLog.DisplayLogAndSave(cstr.GetBuffer(), LV_EVENT);
			gSystemMgr.ComWeiyiConnectFlag = 0;
		}
		else
			gSystemMgr.ComWeiyiConnectFlag = 1;
	}
}


void CRS232Dlg::OnBnClickedButton33()
{
	if (gSystemMgr.ComWeiyiConnectFlag == 0) {
		return;
	}
	memset(gSystemMgr.Output1, 0, sizeof(gSystemMgr.Output1));
	gSystemMgr.m_cComm4.send_data_feedback((BYTE*)gSystemMgr.Send1, sizeof(gSystemMgr.Send1), (BYTE*)gSystemMgr.Output1, sizeof(gSystemMgr.Output1));
	double dis = gSystemMgr.GetWeiyi(gSystemMgr.Output1);
	gSystemMgr.m_dWeiyi[0] = 25.0 - dis * 5.0;
}


void CRS232Dlg::OnBnClickedButton34()
{
	gSystemMgr.m_nButtonValue = 40;
}


void CRS232Dlg::OnBnClickedButton35()
{
	gSystemMgr.m_nButtonValue = 41;
}


void CRS232Dlg::OnBnClickedButton7()
{
	BYTE Pallent_00[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x01, 0x68, 0x3B };
	BYTE Pallent_01[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x02, 0x28, 0x3A };
	BYTE Pallent_02[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x03, 0xE9, 0xFA };
	BYTE Pallent_03[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x04, 0xA8, 0x38 };
	BYTE Pallent_04[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x05, 0x69, 0xF8 };
	BYTE Pallent_05[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x06, 0x29, 0xF9 };
	BYTE Pallent_06[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x07, 0xE8, 0x39 };
	BYTE Pallent_07[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x08, 0xA8, 0x3D };
	BYTE Pallent_08[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x09, 0x69, 0xFD };
	BYTE Pallent_09[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x0A, 0x29, 0xFC };
	BYTE Pallent_10[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x0B, 0xE8, 0x3C };
	BYTE Pallent_11[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x0C, 0xA9, 0xFE };
	BYTE Pallent_12[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x0D, 0x68, 0x3E };
	BYTE Pallent_13[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x0E, 0x28, 0x3F };
	BYTE Pallent_14[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x0F, 0xE9, 0xFF };
	BYTE Pallent_15[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x10, 0xA8, 0x37 };
	BYTE Pallent_16[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x11, 0x69, 0xF7 };
	BYTE Pallent_17[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x12, 0x29, 0xF6 };
	BYTE Pallent_18[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x13, 0xE8, 0x36 };
	BYTE Pallent_19[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x14, 0xA9, 0xF4 };

	BYTE Pallent_20[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x15, 0x68, 0x34 };
	BYTE Pallent_21[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x16, 0x28, 0x35 };
	BYTE Pallent_22[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x17, 0xE9, 0xF5 };
	BYTE Pallent_23[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x18, 0xA9, 0xF1 };
	BYTE Pallent_24[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x19, 0x68, 0x31 };
	BYTE Pallent_25[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x1A, 0x28, 0x30 };
	BYTE Pallent_26[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x1B, 0xE9, 0xF0 };
	BYTE Pallent_27[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x1C, 0xA8, 0x32 };
	BYTE Pallent_28[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x1D, 0x69, 0xF2 };
	BYTE Pallent_29[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x1E, 0x29, 0xF3 };
	BYTE Pallent_30[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x1F, 0xE8, 0x33 };
	BYTE Pallent_31[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x20, 0xA8, 0x23 };
	BYTE Pallent_32[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x21, 0x69, 0xE3 };
	BYTE Pallent_33[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x22, 0x29, 0xE2 };
	BYTE Pallent_34[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x23, 0xE8, 0x22 };
	BYTE Pallent_35[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x24, 0xA9, 0xE0 };
	BYTE Pallent_36[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x25, 0x68, 0x20 };
	BYTE Pallent_37[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x26, 0x28, 0x21 };
	BYTE Pallent_38[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x27, 0xE9, 0xE1 };
	BYTE Pallent_39[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x28, 0xA9, 0xE5 };

	BYTE Pallent_40[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x29, 0x68, 0x25 };
	BYTE Pallent_41[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x2A, 0x28, 0x24 };
	BYTE Pallent_42[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x2B, 0xE9, 0xE4 };
	BYTE Pallent_43[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x2C, 0xA8, 0x26 };
	BYTE Pallent_44[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x2D, 0x69, 0xE6 };
	BYTE Pallent_45[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x2E, 0x29, 0xE7 };
	BYTE Pallent_46[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x2F, 0xE8, 0x27 };
	BYTE Pallent_47[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x30, 0xA9, 0xEF };
	BYTE Pallent_48[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x31, 0x68, 0x2F };
	BYTE Pallent_49[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x32, 0x28, 0x2E };
	BYTE Pallent_50[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x33, 0xE9, 0xEE };
	BYTE Pallent_51[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x34, 0xA8, 0x2C };
	BYTE Pallent_52[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x35, 0x69, 0xEC };
	BYTE Pallent_53[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x36, 0x29, 0xED };
	BYTE Pallent_54[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x37, 0xE8, 0x2D };
	BYTE Pallent_55[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x38, 0xA8, 0x29 };
	BYTE Pallent_56[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x39, 0x69, 0xF9 };
	BYTE Pallent_57[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x3A, 0x29, 0xE8 };
	BYTE Pallent_58[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x3B, 0xE8, 0x28 };
	BYTE Pallent_59[8] = { 0x02, 0x06, 0x00, 0x0A, 0x00, 0x3C, 0xA9, 0xEA };

	char output[150];

	if (IDYES == AfxMessageBox(L"确定 写入当前托盘号 吗？", MB_YESNO))
	{
		memset(output, 0, sizeof(output));
		switch (m_comboPallent.GetCurSel()) {
		case 0:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_00, sizeof(Pallent_00), (BYTE*)output, sizeof(output)); break;
		case 1:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_01, sizeof(Pallent_01), (BYTE*)output, sizeof(output)); break;
		case 2:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_02, sizeof(Pallent_02), (BYTE*)output, sizeof(output)); break;
		case 3:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_03, sizeof(Pallent_03), (BYTE*)output, sizeof(output)); break;
		case 4:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_04, sizeof(Pallent_04), (BYTE*)output, sizeof(output)); break;
		case 5:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_05, sizeof(Pallent_05), (BYTE*)output, sizeof(output)); break;
		case 6:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_06, sizeof(Pallent_06), (BYTE*)output, sizeof(output)); break;
		case 7:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_07, sizeof(Pallent_07), (BYTE*)output, sizeof(output)); break;
		case 8:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_08, sizeof(Pallent_08), (BYTE*)output, sizeof(output)); break;
		case 9:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_09, sizeof(Pallent_09), (BYTE*)output, sizeof(output)); break;
		case 10:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_10, sizeof(Pallent_10), (BYTE*)output, sizeof(output)); break;
		case 11:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_11, sizeof(Pallent_11), (BYTE*)output, sizeof(output)); break;
		case 12:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_12, sizeof(Pallent_12), (BYTE*)output, sizeof(output)); break;
		case 13:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_13, sizeof(Pallent_13), (BYTE*)output, sizeof(output)); break;
		case 14:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_14, sizeof(Pallent_14), (BYTE*)output, sizeof(output)); break;
		case 15:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_15, sizeof(Pallent_15), (BYTE*)output, sizeof(output)); break;
		case 16:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_16, sizeof(Pallent_16), (BYTE*)output, sizeof(output)); break;
		case 17:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_17, sizeof(Pallent_17), (BYTE*)output, sizeof(output)); break;
		case 18:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_18, sizeof(Pallent_18), (BYTE*)output, sizeof(output)); break;
		case 19:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_19, sizeof(Pallent_19), (BYTE*)output, sizeof(output)); break;

		case 20:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_20, sizeof(Pallent_20), (BYTE*)output, sizeof(output)); break;
		case 21:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_21, sizeof(Pallent_21), (BYTE*)output, sizeof(output)); break;
		case 22:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_22, sizeof(Pallent_22), (BYTE*)output, sizeof(output)); break;
		case 23:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_23, sizeof(Pallent_23), (BYTE*)output, sizeof(output)); break;
		case 24:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_24, sizeof(Pallent_24), (BYTE*)output, sizeof(output)); break;
		case 25:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_25, sizeof(Pallent_25), (BYTE*)output, sizeof(output)); break;
		case 26:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_26, sizeof(Pallent_26), (BYTE*)output, sizeof(output)); break;
		case 27:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_27, sizeof(Pallent_27), (BYTE*)output, sizeof(output)); break;
		case 28:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_28, sizeof(Pallent_28), (BYTE*)output, sizeof(output)); break;
		case 29:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_29, sizeof(Pallent_29), (BYTE*)output, sizeof(output)); break;
		case 30:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_30, sizeof(Pallent_30), (BYTE*)output, sizeof(output)); break;
		case 31:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_31, sizeof(Pallent_31), (BYTE*)output, sizeof(output)); break;
		case 32:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_32, sizeof(Pallent_32), (BYTE*)output, sizeof(output)); break;
		case 33:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_33, sizeof(Pallent_33), (BYTE*)output, sizeof(output)); break;
		case 34:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_34, sizeof(Pallent_34), (BYTE*)output, sizeof(output)); break;
		case 35:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_35, sizeof(Pallent_35), (BYTE*)output, sizeof(output)); break;
		case 36:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_36, sizeof(Pallent_36), (BYTE*)output, sizeof(output)); break;
		case 37:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_37, sizeof(Pallent_37), (BYTE*)output, sizeof(output)); break;
		case 38:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_38, sizeof(Pallent_38), (BYTE*)output, sizeof(output)); break;
		case 39:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_39, sizeof(Pallent_39), (BYTE*)output, sizeof(output)); break;

		case 40:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_40, sizeof(Pallent_40), (BYTE*)output, sizeof(output)); break;
		case 41:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_41, sizeof(Pallent_41), (BYTE*)output, sizeof(output)); break;
		case 42:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_42, sizeof(Pallent_42), (BYTE*)output, sizeof(output)); break;
		case 43:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_43, sizeof(Pallent_43), (BYTE*)output, sizeof(output)); break;
		case 44:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_44, sizeof(Pallent_44), (BYTE*)output, sizeof(output)); break;
		case 45:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_45, sizeof(Pallent_45), (BYTE*)output, sizeof(output)); break;
		case 46:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_46, sizeof(Pallent_46), (BYTE*)output, sizeof(output)); break;
		case 47:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_47, sizeof(Pallent_47), (BYTE*)output, sizeof(output)); break;
		case 48:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_48, sizeof(Pallent_48), (BYTE*)output, sizeof(output)); break;
		case 49:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_49, sizeof(Pallent_49), (BYTE*)output, sizeof(output)); break;
		case 50:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_50, sizeof(Pallent_50), (BYTE*)output, sizeof(output)); break;
		case 51:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_51, sizeof(Pallent_51), (BYTE*)output, sizeof(output)); break;
		case 52:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_52, sizeof(Pallent_52), (BYTE*)output, sizeof(output)); break;
		case 53:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_53, sizeof(Pallent_53), (BYTE*)output, sizeof(output)); break;
		case 54:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_54, sizeof(Pallent_54), (BYTE*)output, sizeof(output)); break;
		case 55:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_55, sizeof(Pallent_55), (BYTE*)output, sizeof(output)); break;
		case 56:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_56, sizeof(Pallent_56), (BYTE*)output, sizeof(output)); break;
		case 57:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_57, sizeof(Pallent_57), (BYTE*)output, sizeof(output)); break;
		case 58:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_58, sizeof(Pallent_58), (BYTE*)output, sizeof(output)); break;
		case 59:gSystemMgr.m_cRfidComm1.send_data_feedback((BYTE*)Pallent_59, sizeof(Pallent_59), (BYTE*)output, sizeof(output)); break;
		}
	}
}


void CRS232Dlg::OnBnClickedButton8()
{
	gSystemMgr.ScrewStartFlag = 1;
}


void CRS232Dlg::OnBnClickedButton9()
{
	gSystemMgr.ScrewResetFlag = 1;
}


void CRS232Dlg::OnBnClickedButton37()
{
	if (gSystemMgr.m_cRfidComm4.get_com_port() == NULL) {
		int err = gSystemMgr.m_cRfidComm4.com_open(gSystemMgr.m_nComNo4, gSystemMgr.m_nComPort4, EVENPARITY);
		if (err != 1) {
			CString cstr;
			cstr.Format(L"Com4 Error %d", err);
			gSystemLog.DisplayLogAndSave(cstr.GetBuffer(), LV_EVENT);
			gSystemMgr.Com4ConnectFlag = 0;
		}
		else
			gSystemMgr.Com4ConnectFlag = 1;
	}
}


void CRS232Dlg::OnBnClickedButton38()
{
	gSystemMgr.m_nButtonValue = 45;
}


void CRS232Dlg::OnBnClickedButton39()
{
	gSystemMgr.m_nButtonValue = 46;
}


void CRS232Dlg::OnBnClickedButton40()
{
	gSystemMgr.m_nButtonValue = 47;
}
